package com.main.ok.test;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.greenline.epay.taikang.service.PortalCustomerApplyService;
import com.greenline.epay.taikang.service.TaikangInsuranceService;
import com.greenline.epay.taikang.service.TaikangLogService;
import com.greenline.epay.taikang.service.UserAuthenticationService;
import com.greenline.epay.taikang.service.dto.BaseResponse;
import com.greenline.epay.taikang.service.dto.CheckResponse;
import com.greenline.epay.taikang.service.dto.CommonUserInfoDTO;
//import com.greenline.epay.taikang.service.dto.CommonUserInfoDTO;
//import com.greenline.epay.taikang.service.dto.CommonUserInfoDTO;
import com.greenline.epay.taikang.service.dto.CustomerApplyDTO;
import com.greenline.epay.taikang.service.dto.CustomerApplyRequest;
import com.greenline.epay.taikang.service.dto.ResponseCode;
import com.greenline.epay.taikang.service.dto.ResponseDTO;
import com.greenline.epay.taikang.service.dto.ServiceDTO;
import com.greenline.epay.taikang.service.dto.ServiceLogRequest;
import com.greenline.epay.taikang.service.dto.ServiceLogRequestDTO;
import com.greenline.epay.taikang.service.dto.TaikangInsuranceRequest;
import com.greenline.epay.taikang.service.dto.TaikangInsuranceResponse;
import com.greenline.epay.taikang.service.dto.TelcomUserDTO;
import com.greenline.epay.taikang.service.dto.UserInfoRequest;
import com.greenline.epay.taikang.service.dto.UserInfoRequestDTO;
import com.greenline.epay.taikang.service.dto.query.CustomerApplyQueryDTO;
import com.greenline.epay.taikang.service.dto.query.QueryResultDTO;

import demo.service.dubbo.UserService;

public class Main {

    public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        
        // UserService userService = (UserService) ctx.getBean("userService");
        // System.out.println(userService.check("zuoshuai"));
        // UserAuthenticationService checklogin=(UserAuthenticationService)
        // ctx.getBean("checkLoginService");
        //
        // UserInfoRequest request=new UserInfoRequest();
        // request.setiDNo("110105196209105840");
        // request.setUserName("赵梅雪");
        // BaseResponse response=checklogin.checkUserdentity(request);
        // System.out.println(response.getErrorsInfo());
        /**
         * 用户服务次数校验
         */
        UserAuthenticationService checklogin = (UserAuthenticationService) ctx.getBean("checkLoginService");
//        
//        
         UserInfoRequestDTO request = new UserInfoRequestDTO();
//          request.setiDNo("320106198006013246");
//          request.setUserName("卢可可");
//          request.setiDNo("320921198803042928");
//          request.setUserName("高艳");
          request.setiDNo("211422196406103817");
          request.setUserName("贺长权1");
//          request.setiDNo("230103198308041313");
//          request.setUserName("孙齐");
//          request.setiDNo("330482197901025112");
//          request.setUserName("张忠良");
//          request.setiDNo("210323199102031234");
//          request.setUserName("凉伞");
//         request.setiDNo("110101198001019971");
//         request.setUserName("月月1");
//          request.setiDNo("110101198001010037");
//          request.setUserName("陈明明");
         // request.setiDNo("210105195512092527");
         // request.setUserName("李玉珍");
         // 服务类型 0:电话 1.网络 必传字段
         request.setServerType("1");
         request.setPartnerId("taikang999000000");
         CheckResponse response = checklogin.checkUserService(request);
         System.out.println(response.getErrorsInfo());
         System.out.println("正在使用放号提醒服务个数:" + response.getInserviceCount());

//        userinfo.setiDNo("320201198101142517");
//        userinfo.setUserName("郑荣");
//        userinfo.setMobile("18901870890");
        
        
        
//        CommonUserInfoDTO userinfo = new CommonUserInfoDTO();
//        userinfo.setServerType("0");
////        userinfo.setUserName("蛮子");
////        userinfo.setiDNo("421000197708184708");
////        userinfo.setMobile("13911013611");
////        userinfo.setPartnerId("201405201546245700");
////        userinfo.setGuserId(6512359l);
////        userinfo.setPartnerId("201407221033072360");
//        userinfo.setCustomerId(23l);
//        CheckResponse response = checklogin.commonQueryUserService(userinfo);
//        if (response.getIsSucess()) {
//            List<ServiceDTO> serviceList = response.getServiceList();
//            System.out.println(response.getSource());
//            for (ServiceDTO tmp : serviceList) {
//                System.out.println(tmp.getName() + "--" + tmp.getTotalCount() + "--" + tmp.getValidCount());
//            }
//        } else {
//            System.out.println(response.getErrorsInfo());
//        }

//        CommonUserInfoDTO userinfo = new CommonUserInfoDTO();
//        userinfo.setiDNo("211422196406103817");
//        userinfo.setUserName("贺长权");
//        userinfo.setPartnerId("201407211403056044"); //partnerid
//        userinfo.setServerType("1");//0-电话 1-网络
//        ResponseDTO<Long> res=checklogin.commonQueryCustomerId(userinfo);
//        if(res.getCode().equals(ResponseCode.SUCCESS)){
//            System.out.println(res.getDataResult());
//        }else{
//            System.out.println(res.getErrorMsg());
//        }
        
        
        PortalCustomerApplyService applyService = (PortalCustomerApplyService) ctx.getBean("portalCustomerApplyService");
        // /**
        // * 放号提醒申请
        // */
//         CustomerApplyRequest r = new CustomerApplyRequest();
//         r.setClinicDate("20140530");
//         r.setHospitalId("125982269414752");
//         r.setHospitalDeptId("125982446272843");
//         r.setClinicTypeId("15");
//         r.setExpertId("125982989882678");
//         r.setEndDate("20140531");
//         r.setPatientMobile("18668077883");
//         r.setCustomerId(54l);
//         r.setTimeSection("1");
//         r.setUserId(5560353l);
//         r.setPatientIdCard("211422196406103817");
//         r.setPatientName("贺长权");
////         r.setUserId(8946378l);
//         ResponseDTO<String> response =
//         applyService.sendCustomerApplyOrder(r);
//         if (response.getCode().equals(ResponseCode.SUCCESS)) {
//         System.out.println(response.getMessage());
//         System.out.println(response.getDataResult());
//         } else {
//         System.out.println(response.getErrorMsg()); //
//         // expertId不能为空,patientIdCard为无效身份证,
//         System.out.println(response.getDataResult());
//         }
        /**
         * 放号提醒查询
         */
        // CustomerApplyQueryDTO query = new CustomerApplyQueryDTO();
        // query.setPageIndex(1);
        // query.setPageSize(10);
        // query.setCustomerId(16l);
        // query.setStatus(1);
        // QueryResultDTO<List<CustomerApplyDTO>> resultDto =
        // applyService.queryCustomerApply(query);
        // if (resultDto.getCode().equals(ResponseCode.SUCCESS)) {
        // System.out.println(resultDto.getMessage());//查询成功.
        // System.out.println("获取到:" + resultDto.getDataResult().size() +
        // "条记录"); //获取到:3条记录
        // } else {
        // System.out.println(resultDto.getErrorMsg()); //customerId不可为空
        // }

        /**
         * 放号提醒根据id查询
         */
        // ResponseDTO<CustomerApplyDTO> dto =
        // applyService.queryCustomerApplyByOrderId("");
        // if (dto.getCode().equals(ResponseCode.SUCCESS)) {
        // System.out.println(dto.getMessage());//查询成功
        // CustomerApplyDTO applyDTO = dto.getDataResult();
        // System.out.println(applyDTO.getHospitalDeptName() + "--" +
        // applyDTO.getExpertName());//deptName--expert a
        // } else {
        // System.out.println(dto.getErrorMsg());//orderId不能为空
        // }

        /**
         * 取消放号提醒
         */
//         ResponseDTO<Boolean> result =
//         applyService.cancelCustomerApplyOrder("11");
//         if (result.getCode().equals(ResponseCode.SUCCESS)) {
//         System.out.println(result.getMessage()); //
//         System.out.println(result.getDataResult()); // true
//         } else {
//         System.out.println(result.getErrorMsg()); // 无此记录
//         }
        /**
         * 用户服务记录发送
         */
        // TaikangLogService taikangLogService = (TaikangLogService)
        // ctx.getBean("taikangLogService");
        // ServiceLogRequestDTO logRequest = new ServiceLogRequestDTO();
        // logRequest.setiDNo("110101198001010555");
        // logRequest.setUserName("羽西");
        // logRequest.setServiceTime("201405071412");
        // // logRequest.setPartnerId("taikang999000000");
        // // logRequest.setServerName("私人医生");
        // // logRequest.setServerId("0");
        // BaseResponse ret = taikangLogService.sendServiceLog(logRequest);
        // System.out.println(ret.getIsSucess());
        // System.out.println(ret.getMessage());
        // System.out.println(ret.getErrorsInfo());
        /**
         * 送订单
         */
        TaikangInsuranceService feichangbaoService = (TaikangInsuranceService) ctx.getBean("feichangbaoService");
//        TaikangInsuranceRequest request = new TaikangInsuranceRequest();
        // request.setName("大厦aabb");
        // request.setEmail("zhangsan@yeah.net");
        // request.setPhoneNum("13501243488");
        // request.setIdNo("440701198510054686");
//        request.setName("左帅");
//        request.setEmail("feixueck@126.com");
//        request.setPhoneNum("18668077883");
//        request.setIdNo("410224198710031018");
//        request.setType("tdb"); //铁定保
//    //     <requst><email>84304907@qq.com</email><fromId>52965</fromId><idNo>41072119900103354x</idNo><name>刘</name><phoneNum>18868716048</phoneNum><ssid>TKP_DEFAULT00009900000000002</ssid></requst>
//        ResponseDTO<Boolean> response = feichangbaoService.sendOrderInsurance(request);
//        System.out.println(response.getCode().equals(ResponseCode.SUCCESS));
//        System.out.println("succ:" + response.getMessage());
//        System.out.println("error:" + response.getErrorMsg());
//        System.out.println(response.getDataResult());

        // AuthoPartnerService authoPartnerService =
        // (com.greenline.guser.partner.service.AuthoPartnerService) ctx
        // .getBean("authoPartnerService");
        // System.out.println(authoPartnerService.listPartner(1l));
        /**
         * 查询customer
         */
        // ResponseDTO<Long> responsecustomer =
        // applyService.queryCustomer("贺长权", "211422196406103817",
        // "taikang999000000");
        // if (responsecustomer.getCode().equals(ResponseCode.SUCCESS)) {
        // System.out.println(responsecustomer.getDataResult()); //16
        // System.out.println(responsecustomer.getMessage()); //查询成功
        // } else {
        // System.out.println(responsecustomer.getErrorMsg());//无此用户 name不可为空,
        // }

        
//         ResponseDTO<Long> responsecustomer =
//         applyService.queryCustomer("贺长权", "211422196406103817",
//         "taikang999000000");
        /**
         * 电信接口
         */
//         ResponseDTO<TelcomUserDTO> userdto =
//         applyService.getTelcomUserInfo("E4646D5A2933FCED9EC923128A0A327B",
//         "SFZ");
//         if (userdto.getCode().equals(ResponseCode.SUCCESS)) {
//         System.out.println(userdto.getMessage()); // 查询成功
//         TelcomUserDTO user = userdto.getDataResult();
//         System.out.println(user.getName() + "--" + user.getId() + "--" +
//         user.getIdCard());
//         // 家乐福--54bb2dc4-a8c1-11e3-8ca8-d4ae528c1f4c--310115198703149999
//         } else {
//         System.out.println(userdto.getErrorMsg());// 无此用户 name不可为空,
//         }
        
        

    }
}
